From: Christian Marangi Date: Tue, 21 Nov 2023 20:37:43 +0000 (+0100) Subject: luci-mod-status: reorganize poll function for index page X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=b92c7f696e00a8c3504c00c4c98df7f75192036f;p=project%2Fluci.git luci-mod-status: reorganize poll function for index page Reorganize poll function for index page. Drop the external function and use the poll_status pattern used in other page that use poll.add API. Signed-off-by: Christian Marangi --- diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js index 911c187584..f19a5e4f5d 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js @@ -24,8 +24,8 @@ function invokeIncludesLoad(includes) { return has_load ? Promise.all(tasks) : Promise.resolve(null); } -function startPolling(includes, containers) { - var step = function() { +return view.extend({ + poll_status: function(includes, containers) { return network.flushCache().then(function() { return invokeIncludesLoad(includes); }).then(function(results) { @@ -59,14 +59,8 @@ function startPolling(includes, containers) { ssi.classList.add('fade-in'); } }); - }; - - return step().then(function() { - poll.add(step); - }); -} + }, -return view.extend({ load: function() { return L.resolveDefault(fs.list('/www' + L.resource('view/status/include')), []).then(function(entries) { return Promise.all(entries.filter(function(e) { @@ -103,7 +97,9 @@ return view.extend({ containers.push(container); } - return startPolling(includes, containers).then(function() { + return this.poll_status(includes, containers).then(function() { + return poll.add(L.bind(this.poll_status, this, includes, containers)) + }).then(function() { return rv; }); },